package com.goldfish666.remote_control.entity.base;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;

@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@MappedSuperclass
public class BaseKeyWithDistributedId implements Serializable {
    /**
     * 分布式主键
     */
    @Id
    @GenericGenerator(name = "snowflake", strategy = "com.goldfish666.remote_control.util.SnowflakeIdGenerator")
    @GeneratedValue(generator = "snowflake")
    @Column(name = "id", columnDefinition = "varchar(50) NOT NULL COMMENT '实体ID'")
    protected String id;
}